package com.ryan.dictionary.member.enums;

import java.util.EnumMap;
import java.util.Iterator;
import java.util.Map;

public enum ServiceLevelEnum {
	/**
	 * 普通消费者.
	 */
	COMMONCUSTOMER(100),
	/**
	 * 央行合规实名(只有身份证)
	 */
	SIMPLEREALNAMECUSTOMER(105),
	/**
	 * 实名消费者(身份证+银行卡).
	 */
	REALNAMECUSTOMER(110),
	/**
	 * 个人商家.
	 */
	INDIVIDUALMERCHANT(120),
	/**
	 * 个人大客户.
	 */
	INDIVIDUALVIP(130),
	/**
	 * 新单位客户.
	 */
	NEWORGCUSTOMER(200),
	/**
	 * 中小单位客户.
	 */
	MIDDLEORGCUSTOMER(210),
	/**
	 * 大单位客户.
	 */
	ORGVIP(220);
	private int value;

	public int getValue() {
		return value;
	}

	ServiceLevelEnum(int value) {
		this.value = value;
	}

	public final static Map<ServiceLevelEnum, String> SERVICELEVELMAP;

	static {
		SERVICELEVELMAP = new EnumMap<ServiceLevelEnum, String>(ServiceLevelEnum.class);
		SERVICELEVELMAP.put(ServiceLevelEnum.COMMONCUSTOMER, "普通会员");
		SERVICELEVELMAP.put(ServiceLevelEnum.SIMPLEREALNAMECUSTOMER, "普通实名会员");
		SERVICELEVELMAP.put(ServiceLevelEnum.REALNAMECUSTOMER, "实名会员");
		SERVICELEVELMAP.put(ServiceLevelEnum.INDIVIDUALMERCHANT, "个人商家");
		SERVICELEVELMAP.put(ServiceLevelEnum.INDIVIDUALVIP, "个人大客户");
		SERVICELEVELMAP.put(ServiceLevelEnum.NEWORGCUSTOMER, "新单位客户");
		SERVICELEVELMAP.put(ServiceLevelEnum.MIDDLEORGCUSTOMER, "中小单位客户");
		SERVICELEVELMAP.put(ServiceLevelEnum.ORGVIP, "大单位客户");
	}

	/**
	 * 返回SERVICELEVEL对应的值 Example getValue(SERVICELEVEL.RESERVEMEMBER)
	 * 
	 * @param key
	 * @return int
	 */
	public static int getValue(ServiceLevelEnum key) {
		return key.getValue();
	}

	/**
	 * 返回SERVICELEVEL对应的值 Example getSERVICELEVELValue("RESERVEMEMBER");
	 * 
	 * @param key
	 * @return int
	 */
	public static int getSERVICELEVELValue(String key) {
		return ServiceLevelEnum.valueOf(key).getValue();
	}

	/**
	 * 返回SERVICELEVELMAP Entry list
	 * 
	 * @return Iterator
	 */
	@SuppressWarnings("rawtypes")
	public static Iterator getSERVICELEVELMAPList() {
		return SERVICELEVELMAP.entrySet().iterator();
	}

	/**
	 * 跟据value返回枚举对应的key
	 * 
	 * @param value
	 * @return CRDBTYPE
	 */
	public static ServiceLevelEnum getSERVICELEVELMAPKey(int value) {

		ServiceLevelEnum tmpKey = null;
		for (ServiceLevelEnum tmpEnum : ServiceLevelEnum.values()) {
			if (tmpEnum.value == value) {
				tmpKey = tmpEnum;
				break;
			}
		}
		return tmpKey;
	}

	/**
	 * 返回SERVICELEVEL对应的描述.
	 * @param value int.
	 * @return String
	 */
	public static String getSERVICELEVELDesc(final int value) {
		return ServiceLevelEnum.SERVICELEVELMAP.get(
				ServiceLevelEnum.getSERVICELEVELMAPKey(value));
	}
}
